import React, { Suspense } from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import "./service/request";
import { BrowserRouter } from "react-router-dom";
import "lib-flexible";
import "./api/index";
import { Provider } from "react-redux";
import { store, persistor } from "./store";
import { PersistGate } from "redux-persist/integration/react";
import { CacheProvider } from "./components/keepAlive/CacheContext";
import ErrorBoundary from "./components/errorBoundary";

const root = ReactDOM.createRoot(
  document.getElementById("root") as HTMLElement
);
root.render(
  <Provider store={store}>
    <PersistGate loading={null} persistor={persistor}>
      <CacheProvider>
        <ErrorBoundary>
          <BrowserRouter>
            <Suspense>
              <App />
            </Suspense>
          </BrowserRouter>
        </ErrorBoundary>
      </CacheProvider>
    </PersistGate>
  </Provider>
);

reportWebVitals();
